<h1>Blog: <%= @blog.name %></h1>
<p>Owner: <%= @blog.users.first.name %></p>

<% @posts.each do |post| %>
    <div class="panel">
        <p>Title: <%= post.title %></p>
        <p>Content: <%= post.content %></p>
        <p>Posted: <%= post.created_at %></p>
        <%=link_to "Delete", blog_post_path(blog_id: @blog.id, id: post.id), method: :delete, class: "small button" %>
    </div>
    <% post.comments.each do |comment| %>
        <div class='panel large-10 columns'>
            <p>By: <%= comment.user.name %></p>
            <p><%= comment.content %></p>
        <%=link_to "remove", blog_post_comment_path(blog_id: @blog.id, post_id: post.id, id: comment.id), method: :delete, class: "small button" %>
        </div>
    <% end %>
    <%= form_for 'comment', url: blog_post_comments_path(blog_id: @blog.id, post_id: post.id) do |f|%>
        <fieldset>
            <legend>comment...</legend>
            <%= f.text_field :content %>
            <%= f.submit 'post!', class: 'button small' %>
        </fieldset>
    <% end %>
<% end %>
<% if current_user?(@blog.users.first) %>
    <%= form_for 'post', url: blog_posts_path(@blog.id) do |f| %>
        <fieldset>
            <legend>New Post</legend>
            <%= f.label :title %>
            <%= f.text_field :title %>
            <%= f.label :content %>
            <%= f.text_field :content %>
            <%= f.submit 'Submit', class: 'button' %>
        </fieldset>
    <% end %>
<% end %>

<%= link_to "Back", blogs_path, class: "button" %>
